﻿using System;

namespace AI.Graph {


    public static class ObjectExtension {

        /// <summary>
        /// Returns true if the object is type of the given type. 
        /// </summary>
        public static bool IsTypeOf<T> (this object obj, bool inherit = true) {
            return IsTypeOf (obj, typeof (T), inherit);
        }


        /// <summary>
        /// Returns true if the object is type of the given type. 
        /// </summary>
        public static bool IsTypeOf (this object obj, Type type, bool inherit = true) {
            if (obj == null) return false;
            if (obj.GetType () == type) return true;
            return inherit && obj.GetType ().IsSubclassOf (type);
        }

    }


}